﻿using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Xml.Serialization;

#if NETFX_CORE
    using Windows.Data.Xml.Dom;
#else
using System.Xml;
#endif
namespace Notifications.Templates.WinRT
{
    public sealed class Toast
    {
        public Toast()
        {
            Visuals = new List<Visual>();
        }

            [XmlElement(ElementName = "visual")]
        public IList Visuals { get; set; }

        public XmlDocument Create()
        {
            using (var memoryStream = new MemoryStream())
            {
                XmlSerializer serializer = new XmlSerializer(this.GetType());
                serializer.Serialize(memoryStream, this);

                memoryStream.Position = 0;
                using (var stringReader = new StreamReader(memoryStream))
                {
                    var xmldocument = new XmlDocument();
                    xmldocument.LoadXml(stringReader.ReadToEnd());

                    return xmldocument;
                }
            }
        }
    }
}
